<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>会员积分管理</title>
 <script th:inline="javascript">
/*<![CDATA[*/

           
jQuery.validator.addMethod("checklevelpoint", function(value, element) { 
	var levelPoint = $("#havelogLevelPoint").val();
	var levelstatus = $("#levelPointStatus").val();
	return this.optional(element) || (levelPoint-value>=0 && levelstatus == "REDUCE") || levelstatus == "INCREASE";  
}, "该会员当前等级积分不足");

jQuery.validator.addMethod("checkconsumepoint", function(value, element) { 
	var consumePoint = $("#havelogConsumePoint").val();
	var consumestatus = $("#consumePointStatus").val();
	return this.optional(element) || (consumePoint-value>=0 && consumestatus == "REDUCE") || consumestatus == "INCREASE";  
}, "该会员当前消费积分不足");


$().ready(function() {
	$("#userlogForm").validate({
              rules:{
            	  logRemark:{
                      required:true,
                      maxlength:200
                  },
            	  logLevelPoint:{
                      required:true,
                      digits:true,
                      checklevelpoint:true,
                      min:0,
                      max:99999999
                  },
                  logConsumePoint:{
                      required:true,
                      digits:true,
                      checkconsumepoint:true,
                      min:0,
                      max:99999999
                  }
              },
              messages:{
            	  logRemark:{
            		  required:"请输入积分变动原因",
                      maxlength:"最大不能超过200个字符"
                  },
            	  logLevelPoint:{
                      required:"请输入会员等级积分",
                      number:"请输入正确的等级积分"
                  },
                  logConsumePoint:{
                      required:"请输入会员消费积分",
                      number:"请输入正确的消费积分"
                  }
              }
              
	});
});
	
/*]]>*/
</script>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{'/userlog/index/'+${userId}}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="form">
				<form role="form" th:action="@{'/userlog/save/'+${userId}}" th:object="${userlog}" id="userlogForm" method="post" class="form-horizontal">
					<h4 class="form-section">调整会员积分</h4>
					<input type="hidden" th:field="*{id}" />
					<div class="form-group">
							<label class="control-label col-md-3">当前会员</label>
							<div class="col-md-4" th:text="${user.name}">
								
							</div>
					</div>
					<div class="form-body">
						<div class="form-group" th:class="${#fields.hasErrors('logRemark')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">变动原因<span class="required" aria-required="true">* </span></label>							
							<div class="col-md-4">
								<input type="text" class="form-control" placeholder="变动原因" th:field="*{logRemark}" required=""/>
								<span class="help-block" th:if="${#fields.hasErrors('logRemark')}" th:errors="*{logRemark}">用户名称不能为空</span>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3">等级积分<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<select th:field="*{levelPointStatus}" th:remove="all-but-first" class="form-control" style="width:60px;float:left;">
					                <option th:each="type : ${LevelPointStatus}"
					                        th:value="${type}" th:text="${type.description}"></option>
					            </select> 
								<input type="text" class="form-control" placeholder="等级积分" id="logLevelPoint" name="logLevelPoint" style="width:180px;float:left;" />
								当前积分：<span th:text="${user.levelPoint}"></span><input type="hidden" th:value="${user.LevelPoint}" id="havelogLevelPoint" name="havelogLevelPoint" />
							</div>
						</div>
						
						<div class="form-group">
							<label class="control-label col-md-3">消费积分<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<select th:field="*{consumePointStatus}" th:remove="all-but-first" class="form-control" style="width:60px;float:left;">
					                <option th:each="type : ${ConsumePointStatus}"
					                        th:value="${type}" th:text="${type.description}"></option>
					            </select> 
								<input type="text" class="form-control" placeholder="消费积分" id="logConsumePoint" name="logConsumePoint" style="width:180px;float:left;" />
								当前积分：<span th:text="${user.consumePoint}"></span><input type="hidden" th:value="${user.consumePoint}" id="havelogConsumePoint" name="havelogConsumePoint" />
							</div>
						</div>

					</div>
					<div class="form-actions fluid">
						<div class="col-md-offset-3 col-md-9">
							<button type="submit" class="btn blue" name="sub">提交</button>
						</div>
					</div>
				</form>		
			</div>
		</div>
	</div>
</div>	
</body>
</html>